package org.hxyjs.controller;

import org.hxyjs.dto.DTO;
import org.hxyjs.entity.Carouselmap;
import org.hxyjs.entity.Carouselmap;
import org.hxyjs.page.PageInfo;
import org.hxyjs.service.CarouselmapService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@CrossOrigin
@Controller
@RequestMapping("/carouselmapController")
public class CarouselmapController {
	@Resource
	CarouselmapService carouselmapService;
	@RequestMapping("/getAllCarouselmap")
	@ResponseBody //把方法的返回值按json转换之后 输出到浏览器
    public DTO<Carouselmap> getAllCarouselmap() throws Exception {
    	System.out.println("查询全部轮播图");
		return carouselmapService.getAllCarouselmaps();
    }

	@RequestMapping("/deleteCarouselmapByCmno/{cmno}")
	@ResponseBody
    public DTO<Carouselmap> deleteCarouselmapByCmno(@PathVariable("cmno") String cmno) throws Exception {//如何从页面传入参数到方法 用这个注解绑定变量@PathVariable
    	System.out.println(cmno+"删除轮播图");
    	return carouselmapService.deleteCarouselmapByCmno(cmno);
    }

	@RequestMapping("/updateCarouselmapByCmno")
	@ResponseBody
	public DTO<Carouselmap> updateCarouselmapByCmno(@RequestBody Carouselmap carouselmap) throws Exception {//如何从页面传入参数到方法 用这个注解绑定变量@PathVariable
		System.out.println("修改轮播图");
		return carouselmapService.updateCarouselmapByCmno(carouselmap);
	}


	@RequestMapping("/addCarouselmap")
	@ResponseBody
	public DTO<Carouselmap> addCarouselmap(@RequestBody Carouselmap carouselmap) throws Exception {//如何从页面传入参数到方法 用这个注解绑定变量@PathVariable
		System.out.println("增加轮播图");
		System.out.println(carouselmap);
 		return carouselmapService.addCarouselmap(carouselmap);
	}
	@RequestMapping("/getCarouselmapByPage")
	@ResponseBody
	public DTO<Carouselmap> getCarouselmapByPage(PageInfo pageInfo) throws Exception{//如何从页面传入参数到方法 用这个注解绑定变量@PathVariable
		System.out.println("分页轮播图");
		return carouselmapService.getCarouselmapByPage(pageInfo);
	}

}